Image data generating method and apparatus

ABSTRACT

The present disclosure relates to a image data generating method and device. The device may be configured to obtain a plurality of frames of images of a scene including at least one object, each of the plurality of frames of images is associated with a character distance of a plurality of character distances of the electronic device. For each of the plurality of frames of images, device may determine a target image area, wherein the target image area is an image area on which an object in the scene is sharply focused; and set a focus area in the target image area. Finally, the device may generate an all-focused image by combining the plurality of frames of images, wherein each of the at least one object is sharply focused.

PRIORITY STATEMENT

This application claims the priority benefit of Chinese PatentApplication No. 201510082484.3 filed on Feb. 15, 2015, the disclosure ofwhich is incorporated herein in its entirety by reference.

BACKGROUND

1. Technical Field

The present disclosure relates to the field of image processingtechnologies, and in particular, to an image data generating method andan image data generating apparatus.

2. Related Art

With the rapid development of science and technology, electronic deviceshave become an indispensable part of people's lives. That being said,electronic devices are widely popularized, and also gain a higher userate in various aspects of people, for example, work, studies, and dailycommunication.

For an electronic device that can make an image, when a user needs tomake the frame of image data about a service object, an imageapplication needs to be started to drive imaging hardware for productionin an electronic device (e.g., a camera or a smart phone). When the useris not satisfied with the acquired image data, another frame of imagedata about the service object needs to be made again, and the imageapplication needs to be started again to drive the imaging hardware. Theoperations are complicated and time-consuming.

SUMMARY

Through exemplary embodiments, the present disclosure provides atechnical solution of an image data generating method, so as to obtainan all-focused image of a scene that includes objects at differentdistance from an image taking apparatus.

According to an aspect of the present disclosure, an electronic devicemay comprise imaging hardware; a storage medium including a set ofinstructions for generating image data; and a processor in communicationwith storage medium. When executing the set of instructions, theprocessor is directed to drive the imaging hardware to: obtain aplurality of frames of images of a scene including at least one object,each of the plurality of frames of images is associated with a characterdistance of a plurality of character distances of the electronic device.For each of the plurality of frames of images, the processor maydetermine a target image area, wherein the target image area is an imagearea on which an object in the scene is sharply focused; set a focusarea in the target image area. Finally, the processor may generate anall-focused image by combining the plurality of frames of images,wherein each of the at least one object is sharply focused.

According to another aspect of the present disclosure, a method forgenerating image data may comprise driving imaging hardware of anelectronic device to detect a plurality of frames of depth of fieldimage associated with a plurality of character distances. For each ofthe plurality of frames of the depth of field image, the method maycomprise obtaining a plurality of frames of images of a scene includingat least one object, each of the plurality of frames of images isassociated with a character of a plurality of character distances of theelectronic device. Further, for each of the plurality of frames ofimages, the method may comprise determining a target image area, whereinthe target image area is an image area on which an object in the sceneis sharply focused; setting a focus area in the target image area.Finally, the method may comprise generating an all-focused image bycombining the plurality of frames of images, wherein each of the atleast one object is sharply focused.

Compared with the prior art, the exemplary embodiments of the presentdisclosure have the following advantages:

In the exemplary embodiments of the present disclosure, imaging hardwareis driven to detect the frame of or the plurality of frames of depth offield image by means of one or more character distances, so as to findone or more target image areas; focus areas are respectively set in theone or more target image areas; and the imaging hardware is driven togenerate the frame of or the plurality of frames of image data in oneshot. In this process, a user just needs to complete a generationoperation once to make a selection on different character distances inimage data without performing operations of starting an imageapplication and driving imaging hardware again, which greatly improvesoperational simplicity and reduces time taken.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a flowchart of steps in an exemplary embodiment of an imagedata generating method according to the present disclosure; and

FIG. 2 is a structural block diagram of an exemplary embodiment of animage data generating apparatus according to the present disclosure; and

FIG. 3 is a schematic diagram illustrating an example embodiment of anapparatus embodiment for selecting target image data.

DETAILED DESCRIPTION

To make the foregoing objectives, characteristics, and advantages of thepresent disclosure more obvious and comprehensible, the presentdisclosure is further described in detail below with reference to theaccompanying drawings and specific implementation manners.

Although an auto focusing function has been widely applied, owing tovarious factors such as defects of an auto focusing algorithm, handtrembling, a selection on a focus area, it is easy to make generatedimage data unsatisfactory, and make problems such as a blurred wholepicture, or some unreasonable focus areas, or an unhighlighted image keypoint often arise.

For the problems, with comprehensive consideration into processingcapabilities of a current platform, one of core concepts of embodimentsof the present disclosure is provided. That is, in an operation ofgenerating image data once, a pan-focus generating method of acquiringmultiple images that focus on different depth of field objects, so as tobe selected by a user after the picture is taken, so that a function ofgenerating image data first and focusing afterward is implemented, and aproblem of failed image data generation caused by a reason of focusingis greatly reduced.

FIG. 3 is a schematic diagram illustrating an example embodiment of anapparatus embodiment for selecting target image data as introduced inthe present disclosure. The apparatus may execute methods and softwaresystems introduced in the present disclosure. An apparatus 300 may be acomputing device capable of executing a software system. The apparatus300 may, for example, be a device such as a personal desktop computer ora portable device, such as a camera, a laptop computer, a tabletcomputer, a cellular telephone, or a smart phone.

The apparatus 300 may vary in terms of capabilities or features. Claimedsubject matter is intended to cover a wide range of potentialvariations. For example, the apparatus 300 may include am imageprocessing hardware, such as a camera and/or a webcam. It may alsoinclude a keypad/keyboard 356 and a display 354, such as a liquidcrystal display (LCD), or a display with a high degree of functionality,such as a touch-sensitive color 2D or 3D display. In contrast, however,as another example, a web-enabled apparatus 300 may include one or morephysical or virtual keyboards, and mass storage medium 330.

The apparatus 300 may also include or may execute a variety of operatingsystems 341. The apparatus 300 may include or may execute a variety ofpossible applications 342, such as a photo processing application 345 toprocess images taken from a camera and/or a lens 357. An application 342may enable communication with other devices via a network, such ascommunicating with another computer or apparatus 300 via a network.

Further, the apparatus 300 may include one or more non-transitoryprocessor-readable storage media 330 and one or more processors 322 incommunication with the non-transitory processor-readable storage media330. For example, the non-transitory processor-readable storage media330 may be a RAM memory, flash memory, ROM memory, EPROM memory, EEPROMmemory, registers, hard disk, a removable disk, a CD-ROM, or any otherform of non-transitory storage medium known in the art. The one or morenon-transitory processor-readable storage media 330 may store sets ofinstructions, or units and/or modules that include the sets ofinstructions, for conducting operations and/or method steps described inthe present disclosure. Alternatively, the units and/or modules may behardware disposed in the apparatus 300 configured to conduct operationsand/or method steps described in the present disclosure. The one or moreprocessors may be configured to execute the sets of instructions andperform the methods and/or operations in example embodiments of thepresent disclosure.

Merely for illustration, only one processor will be described inapparatuses that execute operations and/or method steps in the followingexample embodiments. However, it should be note that the apparatuses inthe present disclosure may also include multiple processors, thusoperations and/or method steps that are performed by one processor asdescribed in the present disclosure may also be jointly or separatelyperformed by the multiple processors. For example, if in the presentdisclosure a processor of an apparatus executes both step A and step B,it should be understood that step A and step B may also be performed bytwo different processors jointly or separately in the apparatus (e.g.,the first processor executes step A and the second processor executesstep B, or the first and second processors jointly execute steps A andB).

FIG. 1 shows a flowchart of steps in an exemplary embodiment of an imagedata generating method according to the present disclosure. The methodmay be implemented as a set of instructions and stored in the storagemedium 330 of the apparatus 300. The processor 322 may execute the setof instructions to perform operations of the method. The operations mayinclude:

Step 101: Driving imaging hardware to detect a plurality of frames ofdepth of field image by means of one or more character distances.

Here, the apparatus 300 may be an electronic device having the imaginghardware. The electronic device may specifically include a mobile phone,a tablet computer, a personal digital assistant (PDA), a laptopcomputer, or the like, which is not limited in this embodiment of thepresent disclosure. These electronic devices may support operatingsystems including Windows, Android, 105, WindowsPhone, or the like, andmay generally run an image application of the imaging hardware.

In an exemplary implementation, the imaging hardware may have an imagesensor and an optical element, where the optical element may transmitoptical image information to the image sensor, and the image sensor maybe converted to a sensor used for outputting signals, so as to sense theoptical image information. According to different elements, the imagesensor may be divided into two main types: charge coupled devices (CCDs)and complementary metal-oxide semiconductors (CMOSs). The opticalelement may refer to a component, such as a lens, that receives andadjusts an optical object to implement optical imaging. A lens is a lensgroup generally formed by one or more pieces of optical glass, and abasic unit of the lens is a concave lens, a convex lens, or acombination thereof.

A principle of acquiring image data by the imaging hardware may be that:a collected optical signal is transmitted to the image sensor inside theimaging hardware; the image sensor converts the optical signal to anelectrical signal; and then digital quantization is performed on theelectrical signal to obtain the image data.

The image application may provide a specific control or another triggermanner, and when a user triggers the trigger manner, such as pressing a“start to record” or “start to take picture” button of the apparatus,the image application may drive the imaging hardware to detect the frameof or the plurality of frames of depth of field image by means of theone or more character distances.

The character distance may be a focal distance, i.e., a distance betweenthe apparatus and a focal plane of the apparatus wherein an object isproperly focused. When the scene of the image includes a plurality ofobjects (i.e., service objects), the focal plane may locate in where anobject is. Therefore, the character distance may be a distance betweenthe apparatus and the service object. Different character distance maycorrespond with different depth of field. Here, a depth of field, alsocalled focus range or effective focus range, is the distance between thenearest and farthest objects in a scene that appear acceptably sharp inan image. A depth of field image may be an image that reflects a depthof field of the scene, i.e., objects of different distances from theapparatus 300 may have different sharpness in the image. The sharpnessof an object depends on how far the object is from a focus plane of theapparatus 300. Those objects that are within the depth of field areacceptably sharp, whereas those objects who are outside the depth offield appear blurry in the image. A depth of field image may be apreview image detected in a depth of field range. It may be saved in anon-transitory storage medium of the apparatus 300, or alternatively, asa preview image, it may be written into a buffer memory or cache, but isnot truly generated as a final version of image data to store in thenon-transitory storage medium of the apparatus 300.

The apparatus 300 may further operate under a multiple features state,which includes a predetermined number of different character distances(e.g., focal distance) of the apparatus. For example, the predeterminenumber of character distances may be an arithmetic sequence or asequence of distances corresponding with distances between the apparatusand the objects in the scene. Under the multiple features state, whenthe user presses the “start to record” or “start to take picture” buttonof the apparatus, the apparatus may drive its imaging hardware to shoota predetermined number of (i.e., the plurality of) frames of imagesrespectively corresponding to the predetermined number of characterdistance. Since the predetermined number of character distance is asequence of different numbers, each of the predetermined number offrames of images may corresponds with a different depth of field.

In a exemplary embodiment of the present disclosure, step 101 mayinclude the following substeps:

Substep S11: Driving the imaging hardware to multiple features stateshaving the multiple character distances.

Substep S12: Driving the imaging hardware to detect, in the multiplefeatures states, the plurality of frames of depth of field image

A service object may be one or more objects appear in the depth of fieldimage that the image data generating method may process. For example, ifthe image is a street scene, the service object may be a building, aplant, or a few people appear in the image. The one or more objects maybe distributed in different locations (with different distance from theapparatus) in the street scene, and can generally reflect a light andtransmit the light to the imaging hardware, so that the image datagenerated by the imaging hardware can reflect information of the serviceobject.

In this embodiment of the present disclosure, the character distance maybe a distance between the optical element and an external serviceobject. For example, the optical element may be a lens in the apparatus300.

In an exemplary implementation, the imaging hardware may have a motorthat controls movement thereof, where the motor may move according todifferent current values. Every time the motor moves its location, theimaging hardware may be made to move for a small distance (that is, astep length), and the distance is measured in millimeters ormicrometers. When the imaging hardware stays at a new location, thecharacter distance may change, thereby performing imaging in the one ormore character distances.

Step 102: Determining a target image area in each frame of the pluralityof frames of depth of field image.

The apparatus may first divide each frame of the plurality frames ofimages into a plurality of areas. For example, the apparatus may use agrid to divide each frame into a predetermine number of areas. And then,from the plurality of areas, the apparatus may determine one or moretarget image area.

In an exemplary implementation, the apparatus may determine the targetimage area in the depth of field image every time the frame of depth offield image is detected and/or obtained, or the apparatus may determinethe target image areas in all depth of field images when the depth offield images are detected and/or obtained completely, which is notlimited in this embodiment of the present disclosure.

The target image area may be an image area whose correlation betweenpixels exceeds a preset correlation threshold. Here, the correlationbetween pixels is a measurement that reflects how sharp an image in theimage area, i.e., whether an object in the image area are acceptablyfocused by the apparatus. For example, the correlation between pixels inan image area may be contrast, information entropy, grayscale gradient,or a combination thereof of the pixels in the image area. The higher thecontract, the information entropy, and/or the grayscale gradient, thehigher the correlation between the pixels in the image area. The lowerthe contract, the information entropy, and/or the grayscale gradient,the lower the correlation between the pixels in the image area.

Taking the grayscale gradient as an example to measure the correlation,to identify a target image area, the apparatus 300 may traverse throughthe entire pixels in a frame of image and calculate grayscale gradientamong the pixels in the image areas of the frame of image. The apparatusmay determine that the correlation between pixels in an image area issmall if the grayscale gradient (grayscale change) is small. On theother hand, the apparatus may determine that the correlation betweenpixels in the image area is large if the grayscale gradient is large.Thus based on the grayscale gradient, the apparatus 300 may identify,from a frame of depth of field image, one or more target image areaswithin which the correlation between pixels is above a presetcorrelation threshold. In actual implementation, this means a targetimage area includes a point where an object is sharply focused by theapparatus. Therefore, a target image area may be part or all of anobject in an image that stands out from its surrounding area in theimage, by shape, color, pattern, and/or brightness etc., so that theapparatus 300 may identify the target image area from the frame of depthof field image.

In an exemplary embodiment of the present disclosure, step 102 mayinclude the following substeps:

Substep S21: Dividing each frame of the plurality frames of depth offield image into image areas;

Each frame of the plurality of frames of depth of field images may bedivided in a consistent division manner, such as using a grid to evenlydivide a frame into a predetermined number of image areas.Alternatively, each frame of the plurality of frames of depth of fieldimages may also be divided in an inconsistent division manner, such asdividing a frame into image areas into various sizes and/or variousshapes. Moreover, this embodiment of the present disclosure does notlimit the manner, number and shapes (for example, a square, a circle,and a triangle) of the image areas divided in each frame of theplurality of frames of depth of field images.

In an example of this embodiment of the present disclosure, step S21 mayinclude the following substeps:

Substep S211: Dividing each frame of the plurality of frames of depth offield image into a first sub-area (first image sub-area) and a secondsub-area (second image sub-area). The first sub-area may further includea plurality of sub-sub-area, and the second sub-area may further includea plurality of sub-sub-area. Accordingly, the apparatus 300 may dividethe first sub-area and the second sub-area into image areas underdifferent resolutions.

In this embodiment of the present disclosure, the divided image areaincludes at least one of the first sub-area and the second sub-area.According to an example embodiment, size of the first sub-area may belarger than that of the second sub-area.

In one case, the first sub-area is located in a center location of eachframe of the plurality of frames of depth of field image, and the secondsub-area is located in a peripheral area (e.g., surrounding area) of thefirst sub-area. The apparatus may adopt a finer grid (i.e., a higherresolution in dividing sub-sub-areas) in the first sub-area than thesecond sub-area, so that the accuracy to distinguish variation of thedepth of field at the center area in the depth of field image is higher,and the accuracy to distinguish the depth of field at the peripheralarea in the depth of field image is lower. Here, the accuracy todistinguish the depth of field may refer to a measurement that describeshow small of a depth of field that the image may reflect.

Actual locations, area sizes, and the like of the center location andthe peripheral location may be preselected by a technician or by a userskilled in the art according to actual situations, for example, a centermay be located in a center of the depth of field image, and may also belocated in inclined-left/inclined-right/top/bottom, or the like, whichis not limited in this embodiment of the present disclosure.

In another case, the first sub-area is located in a golden ratiolocation of each frame of the plurality of frames of depth of fieldimage (about 0.618), and the second sub-area is located in the remainderlocation in the frame, so as to increase depth of field precision of thegolden ratio location.

In actual applications, because a user gets used to distributing theservice object near the center location and the golden ratio location,the depth of field precision of the center location and the golden ratiolocation may be high, so as to detect the service object as far aspossible.

Certainly, the division manner described above is just used as anexample. In this embodiment of the present disclosure, another divisionmanner may be set according to actual situations, for example,vertically and horizontally even division, which is also not limited inthis embodiment of the present disclosure. Moreover, except the anotherdivision manner described above, a person skilled in the art may furtheruse yet another division manner according to actual needs, which is alsonot limited in this embodiment of the present disclosure.

Moreover, except the first sub-area and the second sub-area, the dividedimage area may further include another image area. For example, fourcorners of the depth of field image may be divided into a third imagearea or the like, which is also not limited in this embodiment of thepresent disclosure.

Substep S22: Calculating correlation between pixels in the image areafor each frame of the plurality of frames of depth of field image.

If the correlation between the pixels is large, an image grayscalechange is small, an image grads value is small and image entropy is alsosmall. On the contrary, if the correlation between the pixels is small,the image grayscale change is large, the image grads value is large, andthe image entropy is also large.

The image grayscale change may be calculated by means of a spectrumfunction. The spectrum function may be obtained, for example, by meansof Fourier transformation.

Image data with a proper character distance includes more information,and people can better distinguish details therein. The details mean thatthe image data have a distinguishable edge, a very strong gray-levelchange exists locally, and gray-level transition is much stronger.

The grads value may be calculated by means of a gradient function suchas a Tenengrad function, an energy gradient function, a Brennerfunction, and a variance function.

During image processing, the gradient function is often used to extractedge information. The image data with the proper character distance hasan image that has a sharper edge, and the image data should have agreater gradient function value.

The image entropy may be obtained by means of an entropy function. Theentropy function may be based on such a premise in which entropy of theimage data with the proper character distance is greater than entropy ofimage data with an improper character distance (excessively short orexcessively long).

Substep S23: Extracting the image area whose correlation between thepixels exceeds the preset correlation threshold as the target imagearea.

Here, the correlation threshold may be preset. If the correlationbetween the pixels exceeds the correlation threshold, the apparatus 300may determine that the image area includes the service object

When the correlation of pixels is calculated, the apparatus may obtainimage areas whose correlation exceed the correlation threshold, anddetermine these image area may have service objects. Correspondingly,the apparatus may set the image areas as the target image areas. Theapparatus may also mark the target areas, for example, by establishing amapping relationship between the character distance and the target imagearea.

Corresponding to the correlation threshold, an image grayscalethreshold, an image gradient threshold, and an image entropy thresholdmay be set.

When the correlation exceeds the preset correlation threshold, the imagegrayscale change may be less than image grayscale threshold; the imagegradient value may be less than the image gradient threshold; and theimage entropy may be less than the image entropy threshold.

As introduced above, when the predetermined number of character distanceis corresponding with a N number of motor steps in the lens of theapparatus, each pair of two adjacent numbers has a predetermined steplength therebetween, the apparatus may take the plurality of frames ofimages according to the predetermined number of character distances. Tothis end, the apparatus may perform a test for the depth of field to aframe of image according to the predetermined step length. With thepredetermined step length the apparatus may take N steps to go throughand/or traverse the entire frame of image. An objective of the firsttime performance of the depth of field traversing according to the Nstep lengths is to detect whether in N different depth of fielddistances have the service object, instead of generating N-frame imagedata.

After the depth of field traversing is completed, the apparatus mayobtain information about which depth of field distances having theservice object and an approximate location of the service object in ascene.

It should be noted that, in a frame of depth of field image, there mayexist no target image area whose correlation exceeds the presetcorrelation threshold; or there may be only one target image area whosecorrelation exceeds the preset correlation threshold; or there may bemultiple target image areas whose correlation exceeds the presetcorrelation threshold.

Step 103: Separately setting focus areas of each frame of the pluralityof frames of depth of field images in the target image area.

In this step, for each of the plurality of frames of depth of fieldimages, the apparatus may set and/or locate focus areas of the framelocates in the target image areas. For example, if in a frame there isonly one target image area, the apparatus may determine that the focusarea is the target image area. If the frame includes multiple targetareas and locations of these multiple areas concentrate in one area ofthe image, the apparatus may locate the focus area in a center of thearea. The apparatus may mark the focus area for each of the plurality offrames.

The focus area may refer to that auto focusing may be performed, in arange of a specified focus point, on the specified focus point by theexternal service object.

After depth of field detection is performed once, which area (that is,the depth of field) on different depths of field has the service objectcan be acquired.

Therefore, when the image data is officially generated, the focus areasare sequentially directed to the target image area that is labeled tohave the service object, and the imaging hardware is directly dragged toa depth of field (a character distance) corresponding to the targetimage area, which can implement initial focusing, and reduce focusingtime when the image data is generated.

In an exemplary embodiment of the present disclosure, step 103 mayinclude the following substeps:

Substep S31: Setting a target center of the focus area of each frame ofthe plurality of frames of depth of field image to a center of acombined area, where the combined area includes the target image area.

In this embodiment of the present disclosure, one or more target imageareas may be combined into the combined area in a situation where, forexample, the target image areas are adjacent with respect to each otherand/or are concentrated in an area of the frame of image, and the targetcenter of the focus area is set to the center of the combined area.

Or alternatively, in substep S32: Setting the target center of the focusarea of each frame of the plurality of frames of depth of field image toa center of the target image area.

In this embodiment of the present disclosure, in a situation where, forexample, when the target image areas are disperse (or scattered aroundin the image, not concentrated within a small area), in order to furtherincrease a coverage rate of the target image areas, the apparatus 300may individually and separately place a focus area over the center ofeach of the target image areas.

Step 104: Driving the imaging hardware to generate the frame of or theplurality of frames of image data according to the one or more characterdistances and the focus areas.

In this step, the apparatus may obtain and/or reconstruct an all-focusedimage of the scene by combining the plurality of frame of depth of fieldimages into one image, wherein in the all-focused image, every detectedservice objects are sharply focused, although their respective characterdistance may be different.

The reconstruction of the all-focused image may include a process tocombine the images with proper quotiety, details of which is introducedbelow:

Assuming that for the N step length, the apparatus takes N frames of thefield of depth images. The N frames of images forms a group I. Becausethe N frame of depth of field images corresponds to the same scene andis taken by the same apparatus, each of the N frames of depth of fieldimages may include the same matrix of pixels. Assuming each frames ofimages includes x0 pixels at horizontal direction, y0 pixels at verticaldirection, any pixel at location (x,y) in one frame i may correspond toanother pixel in any other frame j in the N frames, wherein j=1, 2 . . .i−1, i+1, . . . N.

The apparatus may determine for each of the N frames of depth of fieldimages, whether the pixel at location (x, y) belongs to a target imagearea. Accordingly, the apparatus may determine, among the N frames ofdepth of field images and for each pixels at location (x, y), M framesof the depth of field images includes a target image area that includesthe pixel.

If M=0, the apparatus may determine that no target image area is at (x,y), i.e., there is no service object at (x, y). Accordingly, theapparatus may determine that the value of the pixel at (x, y) is anaverage value of the N pixels at (x, y) of the N frames:

$J_{({x,y})} = \frac{\sum\limits_{i = 1}^{N}\; {I_{i}\left( {x,y} \right)}}{N}$

wherein I_(i)(x, y) is the value of the pixel at (x, y) location of theith frame of the N frames of depth of field image; J_((x,y)) is thevalue of the pixel at (x, y) location in the all-focused image.

If M>0, the apparatus may determine that at least one target image areais at (x, y), i.e., there are M frames of the depth of field imagesinclude a service object at (x, y). Accordingly, the apparatus maydetermine that the value of the pixel at (x, y) is an average value ofthe M pixels at (x, y) of the M frames:

$J_{({x,y})} = \frac{\sum\limits_{i = 1}^{M}\; {K_{i}\left( {x,y} \right)}}{M}$

wherein K_(i)(x, y) is the value of the pixel at (x, y) location of theith frame among the M frames of depth of field image.

The apparatus may traverse through the entire x0×y0 matrix of pixels ofthe all-focused image to calculate the value of each pixel, and thenobtain the all-focused image.

In an exemplary embodiment of the present disclosure, step 104 mayinclude the following substeps:

Substep S41: Driving the imaging hardware to move to the multiplecharacter distances.

Substep S42: Driving the imaging hardware to place a focus area on thecenter of each target image areas that the apparatus detected in thecurrent characteristic distance, performing focusing processing in thefocus areas, and generating the image data.

In this embodiment of the present disclosure, fine focusing may beperformed in the focus area, and the image data is generated after thefocusing is completed.

Certainly, except performing the focusing processing, the imaginghardware may further perform other processing, for example, setting thenumber of the generated image data, setting an image size, setting acolor effect, setting ISO, setting exposure, setting white balance,setting saturation, setting contrast, and setting sharpness, which isnot limited in this embodiment of the present disclosure.

In actual applications, the service object (a scene) transmits anoptical image generated by means of a lens of the imaging hardware to asurface of the image sensor, converts the optical image into theelectrical signal, and converts the electrical signal to a digital imagesignal by means of analog-digital conversion (A/D); and a digital signalprocessing (DSP) chip or a coding library compresses and inverts thedigital image signal into a format of an image file to store the imagefile.

In an exemplary embodiment of the present disclosure, the methodembodiment may further include the following step:

Step 105: Presenting the plurality of frames of image data.

In this embodiment of the present disclosure, the generated the frame ofor the plurality of frames of image data may be presented, so that theuser selects image data of needed depth of field.

In this embodiment of the present disclosure, imaging hardware is drivento detect the frame or the plurality of frames of depth of field imageby means of one or more character distances, so as to find one or moretarget image areas; focus areas are respectively set in the one or moretarget image areas; and the imaging hardware is driven to generate theframe of or the plurality of frames of image data in one shot. In thisprocess, a user just needs to complete a generation operation once tomake a selection on different character distances in image data withoutperforming operations of starting an image application and drivingimaging hardware again, which greatly improves operational simplicityand reduces time taken.

It should be noted that, for ease of description, the method embodimentsare described as a series of action combinations. However, a personskilled in the art should understand that this embodiment of the presentdisclosure is not limited to the described sequence of the actions,because some steps may be performed in another sequence or performed atthe same time according to this embodiment of the present disclosure. Inaddition, a person skilled in the art should also understand that allthe exemplary embodiments described in this specification belong toexemplary embodiments, and the involved actions are not necessarilymandatory to this embodiment of the present disclosure.

FIG. 2 shows a structural block diagram of an exemplary embodiment of animage data generating apparatus according to the present disclosure, andthe apparatus may specifically include the following modules:

A depth of field detection module 201, configured to drive imaginghardware to detect a plurality of frames of depth of field image bymeans of multiple character distances;

A target image area determining module 202, configured to determine atarget image area in an each frame of the plurality of frames of depthof field image, where the target image area is an image area whosecorrelation between pixels exceeds a preset correlation threshold;

A focus area setting module 203, configured to set a focus area of eachframe of the plurality of frames of depth of field image in the targetimage area; and

An image data generating module 204, configured to drive the imaginghardware to generate the plurality of frames of image data according tothe multiple character distances and the focus areas.

In an exemplary implementation, the imaging hardware may have an opticalelement, and the character distance may be a distance between theoptical element and an external service object.

In an exemplary embodiment of the present disclosure, the depth of fielddetection module 201 may include the following submodules:

A first driving submodule, configured to drive the imaging hardware tomultiple features states having the multiple character distances; and

A second driving submodule, configured to drive the imaging hardware todetect, in the multiple features states, the plurality of frames ofdepth of field image.

In an exemplary embodiment of the present disclosure, the target imagearea determining module 202 may include the following submodules:

A dividing submodule, configured to divide each frame of the pluralityof frames of depth of field image into an image area;

A correlation calculating submodule, configured to calculate correlationbetween pixels in the image area for each frame of the plurality offrames of depth of field image; and

An extracting submodule, configured to extract the image area whosecorrelation between the pixels exceeds the preset correlation thresholdas the target image area.

In an example of this embodiment of the present disclosure, the dividingsubmodule may include the following submodules:

An area dividing submodule, configured to divide each frame of theplurality of frames of depth of field image into a first sub-area and asecond sub-area.

The first sub-area is located in a center location of each frame of theplurality of frames of depth of field image. The second sub-area islocated in the peripheral area and/or surrounding area of the firstsub-area. Alternatively, the first sub-area is located in a golden ratiolocation in each frame of the plurality of frames of depth of fieldimage. Accordingly, the second sub-area is located in the remainder areaof each frame. The first sub-area and the second sub-area may alsoinclude a plurality of sub-sub-areas.

In a exemplary embodiment of the present disclosure, the focus areasetting module 203 may include the following submodules:

A first center setting submodule, configured to set a target center ofthe focus area of each frame of the plurality of frames of depth offield image to a center of a combined area, where the combined areaincludes neighboring target image areas in a same frame of depth offield image; and

A second center setting submodule, configured to set the target centerof the focus area of each frame of the plurality of frames of depth offield image to a center of the target image area.

In an exemplary embodiment of the present disclosure, the image datagenerating module 204 may include the following submodules:

A third driving submodule, configured to drive the imaging hardware tothe multiple features states having the multiple character distances;and

A fourth driving submodule, configured to drive the imaging hardware toperform focusing processing in the focus area corresponding to a currentfeature area, and generate the image data.

In an exemplary embodiment of the present disclosure, the apparatus mayfurther include the following module:

An image data presentation module, configured to present the pluralityof frames of image data and reconstruct the plurality of frames of imagedata into an all-focused image.

The apparatus embodiment is substantially similar to the methodembodiments and therefore is only briefly described, and reference maybe made to the method embodiments for the associated part.

The exemplary embodiments in this specification are all described in aprogressive manner. Description of each of the exemplary embodimentsfocuses on differences from other embodiments, and reference may be madeto each other for the same or similar parts among respectiveembodiments.

A person skilled in the art should understand that the exemplaryembodiments of the present disclosure may be provided as a method, anapparatus, or a computer program product. Therefore, the exemplaryembodiments of the present disclosure may use a form of hardware onlyembodiments, software only embodiments, or embodiments with acombination of software and hardware. Moreover, the exemplaryembodiments of the present disclosure may use a form of a computerprogram product that is implemented on one or more computer-usablestorage media (including but not limited to a disk memory, a CD-ROM, anoptical memory, and the like) that include computer usable program code.

The exemplary embodiments of the present disclosure are described withreference to the flowcharts and/or block diagrams of the method, theterminal device (system), and the computer program product according tothe exemplary embodiments of the present disclosure. It should beunderstood that computer program instructions may be used to implementeach process and/or each block in the flowcharts and/or the blockdiagrams and a combination of a process and/or a block in the flowchartsand/or the block diagrams. These computer program instructions may beprovided for a general-purpose computer, a dedicated computer, anembedded processor, or a processor of any other programmable dataprocessing device to generate a machine, so that the instructionsexecuted by a computer or a processor of any other programmable dataprocessing device generate an apparatus for implementing a specificfunction in one or more processes in the flowcharts and/or in one ormore blocks in the block diagrams.

These computer program instructions may also be stored in a computerreadable memory that can instruct the computer or any other programmabledata processing device to work in a specific manner, so that theinstructions stored in the computer readable memory generate an artifactthat includes an instruction apparatus. The instruction apparatusimplements a specific function in one or more processes in theflowcharts and/or in one or more blocks in the block diagrams.

These computer program instructions may also be loaded onto a computeror another programmable data processing device, so that a series ofoperations and steps are performed on the computer or the otherprogrammable device, thereby generating computer-implemented processing.Therefore, the instructions that are executed on the computer or theother programmable device provide steps for implementing a specificfunction in one or more processes in the flowcharts and/or in one ormore blocks in the block diagrams.

Although some exemplary embodiments of the present disclosure have beendescribed, persons skilled in the art can make changes and modificationsto these embodiments once they learn the basic inventive concept.Therefore, the following claims are intended to be construed as to coverthe exemplary embodiments and all changes and modifications fallingwithin the scope of the exemplary embodiments of the present disclosure.

Finally, it should be further noted that in the present specification,the relational terms such as first and second are used only todifferentiate an entity or operation from another entity or operation,and do not require or imply any actual relationship or sequence betweenthese entities or operations. Moreover, the terms “include”, “include”,and any variants thereof are intended to cover a non-exclusiveinclusion. Therefore, in the context of a process, method, object, ordevice that includes a series of elements, the process, method, object,or terminal device not only includes such elements, but also includesother elements not specified expressly, or may include inherent elementsof the process, method, object, or terminal device. Unless otherwisespecified, an element limited by “include a/an . . . ” does not excludeother same elements existing in the process, the method, the object, orthe terminal device that includes the element.

The foregoing describes an image data generating method and an imagedata generating apparatus according to the present disclosure in detail.Specific examples are used herein to explain principles andimplementation manners of the present disclosure, and description of thefollowing embodiments is only used to help understand the method of thepresent disclosure and core concept thereof. Meanwhile, a person ofordinary skill in the art may make variations in specific implementationmanners and the application scope according to the conception of thepresent disclosure. In conclusion, content of the present descriptionshould not be understood as a limitation to the present disclosure.

1. An electronic device, comprising: imaging hardware; a storage mediumincluding a set of instructions for generating image data; and aprocessor in communication with storage medium, wherein when executingthe set of instructions, the processor is directed to drive the imaginghardware to: obtain a plurality of frames of images of a scene includingat least one object, each of the plurality of frames of images isassociated with a character distance of a plurality of characterdistances of the electronic device; for each of the plurality of framesof images, determine a target image area, wherein the target image areais an image area on which an object in the scene is sharply focused; seta focus area in the target image area; and generate an all-focused imageby combining the plurality of frames of images, wherein each of the atleast one object is sharply focused.
 2. The electronic device accordingto claim 1, wherein the imaging hardware has an optical element, and thecharacter distance is a distance between the optical element and anobject of the at least one object in the scene.
 3. The electronic deviceaccording to claim 1, wherein to obtain the plurality of frames ofimages the processor is further directed to drive the imaging hardwareto: take a depth of field image at each of the plurality of characterdistances.
 4. The electronic device according to claim 1, wherein todetermine the target image area in a frame of image the processor isfurther directed to: divide the frame of the image into at least oneimage area; calculate correlation between pixels in the at least oneimage area; and determine the at least one image area as the targetimage area when the correlation between the pixels in the at least oneimage area exceeds a preset correlation threshold.
 5. The electronicdevice according to claim 4, wherein the correlation between pixels inthe at least one image area comprises a measurement reflecting sharpnessof the frame of image in the image area.
 6. The electronic deviceaccording to claim 4, wherein the at least one image area comprises afirst sub-area and a second sub-area, wherein the first sub-area islocated in a center location of the frame of image, and the secondsub-area is located in peripheral location of the center location; orthe first sub-area is located in a golden ratio location of the frame ofimage, and the second sub-area is located in a location in the at leastone image area other than the first sub-area.
 7. The electronic deviceaccording to claim 1, wherein to set the focus area in the target imagearea the processor is further directed to: set a target center of thefocus area to a center of a combined area, wherein the combined areacomprises the target image area; or set the target center of the focusarea to a center of the target image area.
 8. The electronic deviceaccording to claim 1, wherein the all-focused image includes a matrix oftarget pixels, each target pixel thereof corresponds with an objectpixel in each of the plurality of frames of images; and to generate theall-focused image the processor is further directed to traverse thematrix to determine, for each target pixel of the matrix, which frame ofimage in the plurality of frame of images includes a target image areathat includes the corresponding object pixel.
 9. The electronic deviceaccording to claim 8, wherein if no frame of image in the plurality offrames of images includes a target image area that includes thecorresponding object pixel, the processor is further directed todetermine a value of the target pixel based on values of thecorresponding object pixels in the plurality of frames of images. 10.The electronic device according to claim 8, wherein if at least oneframe of image in the plurality of frames of images includes a targetimage area that includes the corresponding object pixel, the processoris further directed to determine a value of the target pixel based onvalues of the corresponding object pixels in the at least one frame ofimage.
 11. A method for generating image data, comprising: drivingimaging hardware of an electronic device to detect a plurality of framesof depth of field image associated with a plurality of characterdistances; for each of the plurality of frames of the depth of fieldimage, obtaining a plurality of frames of images of a scene including atleast one object, each of the plurality of frames of images isassociated with a character of a plurality of character distances of theelectronic device; for each of the plurality of frames of images,determining a target image area, wherein the target image area is animage area on which an object in the scene is sharply focused; setting afocus area in the target image area; and generating an all-focused imageby combining the plurality of frames of images, wherein each of the atleast one object is sharply focused.
 12. The method according to claim11, wherein the imaging hardware comprises an optical element, and thecharacter distance is a distance between the optical element and anobject of the at least one object in the scene.
 13. The method accordingto claim 11, wherein the obtaining of the plurality of frames of imagescomprises: taking a depth of field image at each of the plurality ofcharacter distance.
 14. The method according to claim 11, wherein thedetermining of the target image area in a frame of image comprises:dividing the frame of the image into at least one image area;calculating correlation between pixels in the at least one image area;and determining the at least one image area as the target image areawhen the correlation between the pixels in the at least one image areaexceeds a preset correlation threshold.
 15. The method according toclaim 14, wherein the correlation between pixels in the at least oneimage area comprises a measurement reflecting sharpness of the frame ofimage in the image area.
 16. The method according to claim 14, whereinthe at least one image area comprises a first sub-area and a secondsub-area, wherein the first sub-area is located in a center location ofthe frame of image, and the second sub-area is located in peripherallocation of the center location; or the first sub-area is located in agolden ratio location of the depth of field image, and the secondsub-area is located in a location in the at least one image area otherthan the first sub-area.
 17. The method according to claim 11, whereinthe setting of the focus area in the target image area comprises:setting a target center of the focus area to a center of a combinedarea, wherein the combined area comprises the target image area; orsetting the target center of the focus area to a center of the targetimage area.
 18. The method according to claim 11, wherein theall-focused image comprises a matrix of target pixels, each target pixelthereof corresponds with an object pixel in each of the plurality offrames of images; and the generating of the all-focused image comprisesdetermining, for each target pixel of the matrix, which frame of imagein the plurality of frame of images includes a target image area thatincludes the corresponding object pixel.
 19. The method according toclaim 18, further comprising if no frame of image in the plurality offrames of images includes a target image area that includes thecorresponding object pixel, determining a value of the target pixelbased on values of the corresponding object pixels in the plurality offrames of images.
 20. The method according to claim 18, furthercomprising: if at least one frame of image in the plurality of frames ofimages includes a target image area that includes the correspondingobject pixel, determining a value of the target pixel based on values ofthe corresponding object pixels in the at least one frame of image.